package com.xhg.model;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.xhg.common.PageNavation;

/**
 *  
 */
public class RolePower extends Model<RolePower> implements BaseModelImpl<RolePower,Long>{
	
	private static final long serialVersionUID = 4372889989943272075L;

	private static String sql;
	
	public static final RolePower dao = new RolePower();

	@Override
	public boolean save(RolePower obj) {
		return false;
	}
	@Override
	public boolean update(RolePower obj) {
		return false;
	}
	@Override
	public RolePower queryById(Long id) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public boolean deleteByIds(String ids) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public Page<RolePower> queryList(PageNavation page) {
		return null;
	}
	/**
	 * 查询全部权限
	 * @param page
	 * @return List<RolePower>
	 */
	public List<Record> queryAllPowersByRoleIds(User user) {
		sql="SELECT p.*, p2.powerName AS fatherName FROM y_power p "
		+ "LEFT JOIN y_power p2 ON ( p2.state=1 AND p2.id=p.fatherId AND p2.used=1) "
		+ "WHERE p.used=1 AND p.state=1";
		List<Record> rpList=Db.find(sql);
		return rpList;
	}
}
